package gamagora.game.utils
{
	import gamagora.game.resources.OSImages;
	
	import org.flixel.FlxG;
	import org.flixel.FlxSprite;
	import org.flixel.FlxText;
	
	public class CreditsList extends FlxSprite
	{
		private static const SPEED:Number = 50.0;
		private static const COLOR:uint = 0xff000000;
		
		private var _peoples:Vector.<FlxText>;
		private var _completeTimer:Number;
		private var _complete:Boolean;
		
		public function CreditsList()
		{
			//super(148, 788, OSImages.MAIN_TITLE);
			super(148, 540, OSImages.MAIN_TITLE);
			
			_peoples = new Vector.<FlxText>();
			_completeTimer = 0;
			//BELHADJAR Fanny  COMBREAS Benoit
			_peoples.push(new FlxText(230, 800, 500, "Game/Level Designers").setFormat(null, 30, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 900, 400, "Pierre COMPIGNIE").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1000, 400, "Jean-Baptiste FOREL").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1100, 400, "Graphic Designers").setFormat(null, 30, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1200, 400, "Florian CHAGUE").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1300, 400, "Romain WANECQUE").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1400, 400, "Programmers").setFormat(null, 30, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1500, 400, "Guillaume BARON").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1600, 400, "Camille MATEO").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1700, 400, "Vincent PIRAULT").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1800, 400, "Sound Designers").setFormat(null, 30, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 1900, 400, "Fanny BELHADJAR").setFormat(null, 20, COLOR, "center", 0x233e58));
			_peoples.push(new FlxText(280, 2000, 400, "Benoit COMBREAS").setFormat(null, 20, COLOR, "center", 0x233e58));
			
			_peoples.push(new FlxText(280, 2400, 400, "Thanks for playing !").setFormat(null, 30, COLOR, "center", 0x233e58));
		}
		
		public override function update():void
		{
			super.update();
			if(_peoples[_peoples.length-1].y > 270)
			{
				var decalY:Number = FlxG.elapsed * SPEED;
				this.y -= decalY;
				for(var i:uint=0;i<_peoples.length;i++)
				{
					_peoples[i].y -= decalY;
				}
			}
			else
			{
				if(!_complete)
				{
					_completeTimer += FlxG.elapsed;
					if(_completeTimer >= 1)
					{
						_complete = true;
					}
				}
			}
		}
		
		public override function draw():void
		{
			super.draw();
			for(var i:uint=0;i<_peoples.length;i++)
			{
				_peoples[i].draw();
			}
		}

		public function get complete():Boolean
		{
			return _complete;
		}
	}
}
